package com.zzxy.spring3.dao.impl;

import com.sun.deploy.security.JarSignature;
import com.zzxy.spring3.dao.IAccountDao;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

public class AccountDaoImpl extends JdbcDaoSupport implements IAccountDao {

    @Override
    public void out(String outer, int money) {
        this.getJdbcTemplate().update("update account set money = money - ? where username = ?",money,outer);

    }


    @Override
    public void in(String inner, int money) {
        this.getJdbcTemplate().update("update account set money = money + ? where username = ?",money,inner);
    }

    //jdbc

//    BasicDataSource dataSource = new BasicDataSource();
//        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
//        dataSource.setUrl("jdbc:mysql:///spring?serverTimezone=UTC");
//        dataSource.setUsername("root");
//        dataSource.setPassword("123456");
//    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
//        jdbcTemplate.update("insert into t_user values (null,?,?)","zhangsan","123");
//        jdbcTemplate.update("update t_user set username = ? where id = ?","lisi",3);
}